package com.crissy.datamasking.controller;


import com.crissy.datamasking.common.Result;
import com.crissy.datamasking.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Crissy-月下闲人
 * @since 2024-04-24
 */
@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {
    @Resource
    private IUserService userService;

    @GetMapping("/isLogin")
    public Result isLogin(@RequestHeader("token") String token) {
        return userService.isLogin(token);
    }

    @GetMapping("/toLogin")
    public Result toLogin(@RequestParam("username") String username, @RequestParam("password") String password) {
        return userService.toLogin(username, password);
    }

    @GetMapping("/toRegister")
    public Result toRegister(@RequestParam("username") String username, @RequestParam("password") String password) {
        return userService.toRegister(username, password);
    }
}
